package com.zhaopin.test;

import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.HashMap;
import java.util.Map;
import java.util.regex.Pattern;

@Slf4j
public abstract class Abc {

    private static final Logger LOGGER = LoggerFactory.getLogger("qaLogger");
    private static final Pattern C = Pattern.compile("c#");
    private static final Pattern C_ADD_ADD = Pattern.compile("c++");
    private static final Pattern D_NET = Pattern.compile(".net");
    private static final Pattern NUMBERS = Pattern.compile("\\d+");
    private static final Pattern WORD = Pattern.compile("[a-zA-Z]+");
    private static final Pattern RE_CHINESES = Pattern.compile("[\u2E80-\u2EFF\u2F00-\u2FDF\u31C0-\u31EF\u3400-\u4DBF\u4E00-\u9FFF\uF900-\uFAFF\uD840\uDC00-\uD869\uDEDF\uD869\uDF00-\uD86D\uDF3F\uD86D\uDF40-\uD86E\uDC1F\uD86E\uDC20-\uD873\uDEAF\uD87E\uDC00-\uD87E\uDE1F]+");
    public static void main(String[] args) {
        String paramStr = "c#工程师";

        char[] chars = paramStr.toCharArray();
        StringBuilder str = new StringBuilder();
        for (int i = 0; i < chars.length; i++) {
            char achar = chars[i];
            if(WORD.matcher(achar+"").matches()){
                str.append(achar);
            }else if(NUMBERS.matcher(achar+"").matches()){
                str.append(achar);
            }else if(RE_CHINESES.matcher(achar+"").matches()){
                str.append(achar);
            }else if(achar == '.'){
                if(i+3 < chars.length && chars[i+1] == 'n' && chars[i+2] == 'e' && chars[i+3] == 't'){
                    str.append(achar);
                }
            }else if(achar == '#' && i-1 >= 0 && chars[i-1]== 'c'){
                str.append(achar);
            }else if(achar == '+'){
                if (i-1 >= 0 && chars[i-1]=='c' && i +1 < chars.length && chars[i+1] == '+'){
                    str.append(achar);
                }else if(i -2 >= 0 && chars[i-1] == '+' && chars[i-2] == 'c'){
                    str.append(achar);
                }
            }
        }

        System.out.println(str.toString());

    }
}

